package hl.leco.colle.set;

/**
 * 一个测试类
 * @author Liu Huan
 */


public class Person2 implements Comparable<Person2> {
    public String name;
    public int age;
    
	//先按年龄排序，如果一样比较姓名
	@Override
	public int compareTo(Person2 o) {
		int n1 = this.getAge() - o.getAge();
		int n2 = this.getName().compareTo(o.getName());
		return n1==0?n2:n1;
	}
    
	public Person2(String name, int age) {
		this.name = name;
		this.age = age;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public int getAge() {
		return age;
	}
	
	public void setAge(int age) {
		this.age = age;
	}
	
	@Override
	public String toString() {
		return "Person{" +
				"name='" + name + '\'' +
				", age=" + age +
				'}';
	}
	
}
